package com.fzf.org.anno.validator;

import com.fzf.org.anno.MyPassword;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class MyPasswordValidator implements ConstraintValidator<MyPassword, String> {
    private static final String REGEX = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{6,16}$";

    @Override
    public boolean isValid(String password, ConstraintValidatorContext constraintValidatorContext) {
        return password != null && password.matches(REGEX);
    }
}
